/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 角色信息
	/// module : structs
	/// </summary>
	public class RoleInfoPOD : IPOD 
    {
        public readonly static Func<RoleInfoPOD> FACTORY = () => new RoleInfoPOD();
		public static Func<RoleInfoPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 玩家pid
        /// </summary>
		public long pid;
		/// <summary>
        /// 名字
        /// </summary>
		public string playerName;
		/// <summary>
        /// 角色id
        /// </summary>
		public int roleCid;
		/// <summary>
        /// 等级
        /// </summary>
		public int level;
		/// <summary>
        /// 唯一ID
        /// </summary>
		public int guid;
		/// <summary>
        /// 创建时间(毫秒时间戳)
        /// </summary>
		public long createTime;
		
		
		
		/*-- constructors --*/
		public RoleInfoPOD() {}
		public RoleInfoPOD(long pid, string playerName, int roleCid, int level, int guid, long createTime) {
			this.pid = pid;
			this.playerName = playerName;
			this.roleCid = roleCid;
			this.level = level;
			this.guid = guid;
			this.createTime = createTime;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_long(pid);
            _out.Write_string(playerName);
            _out.Write_int(roleCid);
            _out.Write_int(level);
            _out.Write_int(guid);
            _out.Write_long(createTime);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            pid = _in.Read_long();
            if(!_in.HasRemaining()) return;
            playerName = _in.Read_string();
            if(!_in.HasRemaining()) return;
            roleCid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            level = _in.Read_int();
            if(!_in.HasRemaining()) return;
            guid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            createTime = _in.Read_long();
        }
		
		public RoleInfoPOD Clone() {
            RoleInfoPOD o = DynamicFactory();
            o.pid = pid;
            o.playerName = playerName;
            o.roleCid = roleCid;
            o.level = level;
            o.guid = guid;
            o.createTime = createTime;
            return o;
        }
        
        public void Clear() {
            pid = default;
            playerName = default;
            roleCid = default;
            level = default;
            guid = default;
            createTime = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "RoleInfoPOD [";
			str += "pid=";
			str += pid;
			str += ", playerName=";
			str += playerName;
			str += ", roleCid=";
			str += roleCid;
			str += ", level=";
			str += level;
			str += ", guid=";
			str += guid;
			str += ", createTime=";
			str += createTime;
			str += "]";
			return str;
		}
		
	}
}